package Thread;

class SimpleArrayList01 {


    private Object[] array;
    private int size;
    public SimpleArrayList01(int capacity)
    {
        array = new Object[capacity];
    }

    public synchronized void add(Object obj)
    {

        if(size == array.length)
        {
            Object[] newArray = new Object[array.length * 2];
            System.arraycopy(array, 0, newArray, 0, array.length);
            array = newArray;
        }
        array[size] = obj;
        size++;
    }
    public int getsize() {
        return size;
    }
}
        }
public class SimpleArrayList01 {
    public static void main(String[] args)throws InterruptedException
    {
        SimpleArrayList01 list = new SimpleArrayList01(16);
        for(int i = 0; i < 10; i++)
        {
            list.add(i);
        }
    }
}

public synchronized void remove(Object obj) {
    for(int i = 0; i < size; i++)
    {
        if(array[i].equals(obj))
        {
            for(int j = i; j < size - 1; j++)
            {
                array[j] = array[j + 1];
            }
            System.arraycopy(array, i + 1, array, i, size - i - 1);
            array[size - 1] = null;
            size--;
            return;
        }
    }
}



























